package cn.tedu.oop.park;/**
 * @Author 金帮嘉诚 @Date 2021-07-24 星期六 11:34
 */
/*本类用于测试包装类*/

/**
 * 知识点
 */
public class Parking {
    public static void main(String[] args) {
        int a = 1;
        Integer integer, integer1;
        integer = a;
        integer = Integer.valueOf(a);//上一句等价于此句
        integer1 = new Integer(a);
        System.out.println(integer == integer1);//false

        Integer a1, a2;
        a1 = Integer.valueOf(127);
        a2 = Integer.valueOf(127);
        System.out.println(a1 == a2);//true

        Integer c1, c2;
        c1 = Integer.valueOf(128);
        c2 = Integer.valueOf(128);
        System.out.println(c1 == c2);//false,高效只能是 Integer Short Byte类型的 用valueOf 且赋值范围在1-127


        Short sh1, sh2;
        sh1 = Short.valueOf((short) 128);
        sh2 = Short.valueOf((short) 128);
        System.out.println(sh1);
        System.out.println(sh1 == sh2);

//自动装箱
        integer = a;
        integer = Integer.valueOf(a);//上一句等价于此句
        //自动拆箱
        int b = integer;
        b = integer.intValue();//上一句等价于此句
    }
}
